#include "scorepanel.h"
#include "ui_scorepanel.h"

const QString MYCOLOR[] = { "black", "white", "red", "blue", "green" };

ScorePanel::ScorePanel(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::ScorePanel)
{
    ui->setupUi(this);
    m_listLabel << ui->meScore << ui->leftScore << ui->rightScore
                << ui->meTitle << ui->leftTitle << ui->rightTitle
                << ui->score1 << ui->score2 << ui->score3;
}

ScorePanel::~ScorePanel()
{
    delete ui;
}

// 设置玩家的分数
void ScorePanel::setScores(int left, int right, int user)
{
    ui->leftScore->setText(QString::number(left));
    ui->rightScore->setText(QString::number(right));
    ui->meScore->setText(QString::number(user));
}

// 设置字体的大小
void ScorePanel::setMyFontSize(int point)
{
    QFont font("微软雅黑", point, QFont::Bold);
    for (int i = 0; i < m_listLabel.size(); ++ i)  {
        m_listLabel[i]->setFont(font);
    }
}

// 设置字体的颜色
void ScorePanel::setMyFontColor(FontColor color)
{
    QString style = QString("QLabel{color:%1}").arg(MYCOLOR[color]);
    for (int i = 0; i < m_listLabel.size(); ++ i) {
        m_listLabel[i]->setStyleSheet(style);
    }
}
